<?php
	$relations = $model->getMetadata()->relations;
	//CVarDumper::dump($relations, 2, true);die;
	if(!$this->useGroup) $this->fields = array('baseInfo'=>$this->fields);
	foreach(array_keys($this->fields) as $one) {
		$title[$one] = $form->labelEx($model, $one);
	}
	$this->beginWidget('Block', array('title' => $title));
	
	$relations = $model->getMetadata()->relations;
	foreach($this->fields as $gName=>$gFields) {
		echo "<div class='tab' id='{$gName}'>";
		if(isset($relations[$gName]) && $relations[$gName] instanceof CHasManyRelation) {
			
			Yii::createComponent(array(
				'class' => 'BusinessDistrictForm',
				'model' => $model,
				'activeForm' => $form,
				'fields' => $gFields,
				'relationName' => $gName,
			))->render();
		
		
		} else {
			echo "<table class='detail mgb10'>";
			foreach($gFields as $name=>$field) {
				if(!$field->getIsVisible()) continue;
				$label = $model->getAttributeLabel($name);
				$width = strlen($label) * 7;
				echo 
				'<tr>'.
					'<th class="vtop" width="'.$width.'px">'.$form->labelEx($model, $name).'：</th>'.
					'<td>'.$field->render().
					$form->error($model, $name).'</td>'.
				'</tr>';
			}
			echo '</table>';
		}
		echo '</div>';
		
	}
	
	$this->endWidget();
?>
